package com.axun.ckz.yytmanager.util;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.view.View;

public class StatutBarTools {

    public static int getStatusBarHeight(Context context) {
        int result = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen",
                "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }

    /**
     * 获取导航栏高度
     * @param context
     * @return
     */
    public static int getDaoHangHeight(Context context) {
        int result = 0;
        int resourceId=0;
        int rid = context.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
        if (rid!=0){
            resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");

            return context.getResources().getDimensionPixelSize(resourceId);
        }else
            return 0;
    }

    public static void setActivityPadding(Activity activity){
        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
            View view = activity.getWindow().getDecorView();
            view.setPadding(0,0,0,StatutBarTools.getDaoHangHeight(activity));
        }
    }
}
